package com.hualan.service;


import com.hualan.domain.Course;
import com.hualan.domain.CourseCui;
import com.hualan.mapper.CourseMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseServicecui {
    @Autowired
    private CourseMapper courseMapper;

    // 根据id查询课程

    public Course findCourseById(Long id){

        return courseMapper.selectByPrimaryKey(id);
    }

  /*  //查看所有小程序用
    public List<Course> findAllCourse22(){
        return courseMapper.selectAllCourse();
    }
*/
    //查看所有
    public List<Course> findAllCourse(){
        return courseMapper.selectAllCourse();
    }
  /*  public PageInfo<Course> findAllCourse(int pageNum,int pageSize) {
        //加载分页设置
        int count = courseMapper.selectAlltotal();//通过获取总条数接口获取总条数
        PageHelper.startPage(pageNum,pageSize);
        List<Course> list = courseMapper.selectAllCourse();
        PageInfo<Course> pageInfo = new PageInfo<Course>(list);
        pageInfo.setTotal(count);
        return pageInfo;
    }*/

    //动态增加
    public int addSelective(Course record){
        return courseMapper.insertSelective(record);
    }

    //根据id删除
    public  int removeById(Long id){
        return courseMapper.deleteByPrimaryKey(id);
    }


    //动态修改
    public  int changeSelective(CourseCui courseCui){
        return courseMapper.updateByPrimaryKeySelectiveCui(courseCui);
    }

    //通过课程名模糊查询
    public List<Course> findByLikeCourseName(String coursename){
        return courseMapper.selectByLikeCourseName(coursename);
    }


}
